<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

class UserController extends Controller
{

    protected function authenticate(Request $request)
    {
        $request->request->add([
            'username' => $request->username,
            'password' => $request->password,
            'grant_type' => 'password',
            'client_id' => config('lboy.oauth_pass_grant.client_id'),
            'client_secret' => config('lboy.oauth_pass_grant.secret'),
            'scope' => '*'
        ]);

        $proxy = Request::create(
            'oauth/token',
            'POST'
        );

        return Route::dispatch($proxy);
    }

    public function info(Request $request)
    {
        //return response()->json($user, 200);
        return response()->json($request->user(), 200);
    }
}
